<?php
class user_discountCategories_TCEforms
{
	function user_getDiscountCategoriesField($PA, $pObj)
	{
		if (!isset($pObj->additionalCode_pre['scriptaculous']))
		{
			$pObj->additionalCode_pre['scriptaculous'] = '
				<script type="text/javascript" src="'.t3lib_extMgm::extRelPath('user_farm_extjs').'scriptaculous.js?load=effects"></script>
			';
		}
		
		if (!isset($pObj->additionalCode_pre['prototypeAdapter']))
		{
			$pObj->additionalCode_pre['prototypeAdapter'] = '
				<script type="text/javascript" src="'.t3lib_extMgm::extRelPath('user_farm_extjs').'ext-prototype-adapter.js"></script>
			';
		}
		
		if (!isset($pObj->additionalCode_pre['extjs']))
		{
			$pObj->additionalCode_pre['extjs'] = '
				<script type="text/javascript" src="'.t3lib_extMgm::extRelPath('user_farm_extjs').'ext-all-debug.js"></script>
				<script type="text/javascript" src="'.t3lib_extMgm::extRelPath('user_farm_extjs').'locale/ext-lang-ru.js"></script>
			';
		}
		
		if (!isset($pObj->additionalCode_pre['extjscss']))
		{
			$pObj->additionalCode_pre['extjscss'] = '
				<link rel="stylesheet" type="text/css" href="'.t3lib_extMgm::extRelPath('user_farm_extjs').'resources/css/ext-all.css" />
				<link rel="stylesheet" type="text/css" href="'.t3lib_extMgm::extRelPath('user_farm_extjs').'resources/css/xtheme-gray.css" />
			';
		}
		
		if (!isset($pObj->additionalCode_pre['discountCategoriesPanel']))
		{
			$pObj->additionalCode_pre['discountPanel'] = '
				<script type="text/javascript" src="'.t3lib_extMgm::extRelPath('user_farm_commerce').'resources/scripts/select-discount-categories-control.js">
				</script>
				<link rel="stylesheet" type="text/css" href="'.t3lib_extMgm::extRelPath('user_farm_commerce').'resources/css/category-selection-panel.css" />
			';
		}
		
		return '
			<input type="hidden" name="data[user_farm_commerce_discounts]['.$PA['row']['uid'].'][categories]" value="33" />
			<div id="data[user_farm_commerce_discounts]['.$PA['row']['uid'].'][categories_panel]"></div>
			<script type="text/javascript">
				var DiscountCategoriesField_'.$PA['row']['uid'].' = new Farm.SelectDiscountCategoriesControl({
					uid: "'.$PA['row']['uid'].'",
					selectedCategories: [{uid: 33, title: "Сувенирно-полиграфическая продукция"}]
				});
			</script>
			';
			
	}
}
?>